using System;
using System.Collections.Generic;

namespace Sponsorship.Domain
{
    /// <summary>
    /// Defines a common base class for implementations of <see cref="IEvent"/>.
    /// The concrete domain events are defined in the Contracts.tt file.
    /// </summary>
    public abstract class Event : IEvent
    {
        private readonly Dictionary<string, string> _headers = new Dictionary<string, string>();

        public string GetHeaderValue (string key)
        {
            return _headers[key];
        }

        public int GetVersion()
        {
            return Int32.Parse (GetHeaderValue (EventVersionKey));
        }

        public void SetHeader (string key, string value)
        {
            _headers[key] = value;
        }

        public const string EventVersionKey = "EventVersion";
    }
}